from apps.verifications.constant import YUNTONGXUN_EXPIRE_TIME
from celery_tasks.main import app
from libs.yuntongxun.sms import CCP
import logging
logger = logging.getLogger('django')


@app.task(bind=True,default_retry_delay=5,name='send_sms')
def send_sms_code(self,mobile, sms_code):
    try:
        result=CCP().send_template_sms(mobile, [sms_code, YUNTONGXUN_EXPIRE_TIME], 1)
        if result != 0:
            raise Exception('下单失败')


    except Exception as exc:
        logger.error(exc)
        raise self.retry(exc=exc,max_retries=3)


